package com.wyvoid.forum.service.impl;

import com.wyvoid.forum.service.IUserGroupService;
import com.wyvoid.forum.dao.IUserGroupDAO;
import com.wyvoid.forum.dao.IAdminGroupDAO;
import com.wyvoid.forum.domain.UserGroup;
import com.wyvoid.forum.domain.AdminGroup;
import com.wyvoid.forum.Constant;

import java.util.List;

import org.springframework.transaction.annotation.Transactional;

/**
 * User: cjp
 * Date: 2007-7-1
 * Time: 21:13:13
 */
@Transactional
public class UserGroupService implements IUserGroupService {
    private IUserGroupDAO userGroupDAO;
    private IAdminGroupDAO adminGroupDAO;

    public void setUserGroupDAO(IUserGroupDAO userGroupDAO) {
        this.userGroupDAO = userGroupDAO;
    }

    public void setAdminGroupDAO(IAdminGroupDAO adminGroupDAO) {
        this.adminGroupDAO = adminGroupDAO;
    }

    public List<UserGroup> getMemberUserGroups() {
        return userGroupDAO.getUserGroups(Constant.UserGroup.TYPE_MEMBER);
    }

    public List<UserGroup> getOtherUserGroups() {
        return userGroupDAO.getUserGroups(Constant.UserGroup.TYPE_OTHER);
    }

    public List<UserGroup> getSystemUserGroups() {
        return userGroupDAO.getUserGroups(Constant.UserGroup.TYPE_SYSTEM);
    }

    public List<UserGroup> getAdminGroups() {
        return userGroupDAO.getAdminGroups();
    }

    public UserGroup getUserGroup(long groupId) {
        return userGroupDAO.getById(groupId);
    }

    public AdminGroup getAdminGroup(long adminGroupId) {
        return adminGroupDAO.getById(adminGroupId);
    }

    public void updateUserGroup(UserGroup userGroup) {
        userGroupDAO.update(userGroup);
    }

    public UserGroup getUserGroupById(long userGroupId) {
       return userGroupDAO.getById(userGroupId);
    }

    public void saveUserGroup(UserGroup userGroup) {
        userGroupDAO.create(userGroup);
    }

    public void deleteUserGroup(UserGroup userGroup) {
        userGroupDAO.delete(userGroup);
    }
}
